<template>
  <div class="header">
    <h1>{{title}}</h1>
    <i @click="back" class="cubeic-back" v-if="$routerHistory.canBack()" id="cubeic-back"></i>
    <div class="extend">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ""
    }
  },
  methods: {
    back() {
      //利用了h5的history，但有bug
      //在历史记录中有记录时，后退有可能跳出vue的应用
      this.$router.goBack();
    }
  }
};
</script>

<style lang="scss" scoped>
.header {
  position: relative;
  height: 44px;
  line-height: 44px;
  text-align: center;
  background: #edf0f4;
  .extend {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0 15px;
    color: #fc915b;
  }
}
#cubeic-back {
  position: absolute;
    top: 0;
    left: 0;
    padding: 0 15px;
    color: #fc915b;
}
</style>
